package vn.vfriends.id.bean;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author tuan@vfriends.vn
 */
@ManagedBean
@ViewScoped
public class UtilBean implements Serializable {

    public String formatDate(Date date) {
        if (date == null) {
            return "";
        }
        return DateFormat.getInstance().format(date);
    }

    public String formatDate(Date date, String format) {
        if (date == null) {
            return "";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}
